import moment from 'moment'
import { getAction, httpAction } from '@api/manage'

export const GfxyYearRangePickerMixin = {
  components: {

  },
  data() {
    return {
      startDateOpen:false,
      endDateOpen:false,
    }
  },
  methods: {
    moment,
    openChangeStartDate(status){
      if (status) {
        this.startDateOpen = true;
      } else {
        this.startDateOpen = false;
      }
    },
    openChangeEndDate(status){
      if (status) {
        this.endDateOpen = true;
      } else {
        this.endDateOpen = false;
      }
    },
    disabledStartDate(startValue){
      //startValue moment
      const _startValue = startValue.format('YYYY');
      const _endValue = this.model.endTime;
      if (!startValue || !_endValue || _endValue == '') {
        return false;
      }
      return _startValue > _endValue;
    },
    disabledEndDate(endValue){
      const _startValue = this.model.startTime;
      const _endValue = endValue.format('YYYY');
      if (!endValue || !_startValue || _startValue == '') {
        return false;
      }
      return _startValue > _endValue;
    },

    // 选择年之后 关闭弹框
    panelStartChange: function(value){
      // const endOfYear = moment().endOf('year')
      this.model.startTime = value.format('YYYY');
      this.startDateOpen = false;
    },
    // 选择年之后 关闭弹框
    panelEndChange: function(value){
      this.model.endTime = value.format('YYYY');
      this.endDateOpen = false;

    },
  }
}